//创建路由器
import VueRouter from "vue-router";
//引入组件
const detail = ()=>import('../components/newsDetail/newDetail.vue');
const home = ()=>import('../components/Nav.vue');
const personnalCenter = ()=>import('../components/Person/PersonnalCenter.vue')
const my = ()=>import('../components/Person/AboutMyself.vue')
const config =()=>import('../components/Person/SettingPerson.vue')
const search =()=>import('../components/search/search.vue')

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new VueRouter({
  routes: [
    {
      path:'',
      component:home,
    },
    {
      path:'/search',
      component:search
    },
    {
      path:'/detail/:id',
      component:detail
    },
    {
      path:'/person',
      component:personnalCenter,
      children:[
        {
          path:'my',
          component:my,
          name:'My'
        },
        {
          path:'config',
          component:config
        },
      ]
    }
  ],
  mode:'history'
});
